package ljl.alg.wangzheng_camp.round1.tree;

import commons.TreeNode;

public class _offer54_kth_largest {
    
    public int kthLargest(TreeNode root, int k) {
        this.k = k;
        dfs(root);
        return res;
    }
    int res;
    int k;
    void dfs(TreeNode node) {
        if (node == null) return;
        dfs(node.right);
        if (--k == 0) {
            res = node.val;
            return;
        }
        dfs(node.left);
    }
}
